  <script src="http://maps.google.com/maps?file=api&v=2&sensor=true&key=ABQIAAAAOwWCGwRYp76jMzcTHSAZJxRiKXZ7DXrLzxyWAdGBhEoVkrucchSRf8ZK-in_QWw4Q9UXcM6WsNif1Q"
    type="text/javascript">
  </script>
<div id="left">
<div id="breadcrumb">Story "<?php echo $story['Story']['title']; ?>" in <?php echo $html->link($story['City']['name'], '/cities/view/' . $story['City']['id']); ?> by <?php echo $html->link($story['User']['username'], '/users/view/' . $story['User']['id']); ?></div>
<div class="post">
<p>This story is at (<?php echo $story['Story']['latitude']; ?>, <?php echo $story['Story']['longitude']; ?>). <?php if($story['User']['id'] == $me['User']['id']): ?>You may add images to the story by clicking on the "Add Image" button to the right.<?php endif; ?></p>
</div>
<div class="google_maps_city"><div id="map_canvas" style="width: 587px; height: 200px;"></div></div>
 	<script type="text/javascript">
		var center;
		var markerLoc;
		var map;
		var blueIcon;
		function initialize() {
		  map = new GMap2(document.getElementById("map_canvas"));
		  center = new GLatLng(<?php echo $story['Story']['latitude']; ?>, <?php echo $story['Story']['longitude']; ?>);
		  map.setCenter(center, 17);
		  map.setUIToDefault();
		  map.setMapType(G_HYBRID_MAP);
		  blueIcon = new GIcon(G_DEFAULT_ICON);
		  blueIcon.image = "http://maps.google.com/mapfiles/ms/icons/blue-dot.png";
		  blueIcon.iconSize = new GSize(32,32);
		  blueIcon.iconAnchor = new GPoint(15,31);
		  
		  var marker = new GMarker(map.getCenter(), {draggable: false, icon: blueIcon});
		  map.addOverlay(marker);
		}
	</script><p></p>
<div class="stories view">
<h2><?php  echo $story['Story']['title']; ?></h2>
<p>In <?php 
			if (strlen($story['City']['Region']['name']))
			{ 
				echo $html->link($story['City']['name'] . ', ' . $story['City']['Region']['name'] . ', ' . $story['City']['Country']['name'], array('controller'=> 'cities', 'action'=>'view', $story['City']['id']));
			}
			else
			{
				echo $html->link($story['City']['name'] . ', ' . $story['City']['Country']['name'], array('controller'=> 'cities', 'action'=>'view', $story['City']['id']));
			}
?> written by <?php echo $html->link($story['User']['username'], '/users/view/' . $story['User']['id']); ?> on <?php echo $time->nice($story['Story']['created']); ?>.</p>
<div style="padding:10px;">
 <p style="font-size: 12px"><?php echo $story['Story']['message']; ?></p>
</div>
</div>
<div class="columns">
						<p><div class="colwide">
                            
                            <?php if(empty($posts)): ?>
                            <div class="colpostempty" style="height: 60px;"><h3 class="subhead">No posts have been added.</h3> 
								<p>Be the first one to add one! Click "New Post" below!</p>
                            </div>
                        	<?php endif; ?>
                        
                    	    <?php if(!empty($posts)): ?>
       						<?php foreach($posts as $post): ?>
                               	   	<div class="colpost"><h3 class="subhead"><?php echo $time->nice($post['Post']['created']); ?> by <?php echo $html->link($post['User']['username'], '/profiles/view/' . $post['User']['Profile']['id'], array('name' => 'post_' . $post['Post']['id'])); ?> of <?php echo $html->link($post['User']['Profile']['City']['name'], '/cities/view/' . $post['User']['Profile']['City']['id']); ?>:</h3> 
										<p><?php echo $extendedhtml->image('/images/thumb/' . $post['User']['Profile']['Image']['id'] . '/?w=50&h=50', array('class' => 'leftpost'), '/profiles/view/' . $post['User']['Profile']['id'], array()); ?><?php echo $post['Post']['text']; ?></p>
		                            </div>
		                            <h3 class="sublink"><?php if( $post['User']['id'] == $user['User']['id'] || $story['Story']['user_id'] == $user['User']['id']) echo $html->link('Delete Post', array('controller' => 'posts', 'action' => 'delete', $post['Post']['id'])); ?></h3>
                         	   <?php endforeach; ?>
                	        <?php endif; ?>
                            <div class="colnewpost" style="display: none;" id="newpostform"><h3 class="subhead">Write on <?php echo $story['User']['username'] . "'s story board" ; ?></h3> 
								<?php echo $form->create('Post', array('action' => 'add', 'class' => 'formcenter')); ?>							
						 		<?php echo $form->textarea('text', array('id' => 'postarea')); ?>
						 		<?php echo $form->hidden('story_id', array('value' => $story['Story']['id'])); ?>
						 		<?php echo $form->submit('/img/submit.jpg' , array( 'alt' => 'submit', 'id' => 'submitpost')); ?> 
						 		<?php echo $form->end(); ?>
                            </div>
                            <h3 class="subfoot"><?php echo (($user || $isMe) ? '<a href="javascript:void();" onClick="Effect.BlindDown(\'newpostform\'); return false;">New Post</a>' : '<strong>You must be logged in to add a post to a story!</strong>' ); ?></h3>
						</div></p>
					</div>
					
</div>
<div id="sidebar">
	<div class="actions">
	<?php 
		if($story['User']['id'] == $me['User']['id']){
			echo '<div style="padding-bottom:3px">';
			echo '<form method="GET" action="/images/add/" class="formcenter">'; 
			echo '<input type="hidden" name="story_id" value="' . $story['Story']['id'] . '">';
		    echo '<input type="image" src="/img/addimage.jpg" alt="Add Image" />';
			echo '</form>';
			echo '</div>';
			//echo $extendedhtml->image('/img/addimage.jpg', array('class' => 'formcenter'), '/images/add/?story_id=' . $story['Story']['id'], array()); 
		}
		
		?>
	</div>

    <h2>Images</h2>
   	<?php if (!empty($story['Image'])):?>
	<table style="border:0" width="100%" align="center">
	<tr>
		<?php $i = 0; ?>
		<?php foreach($story['Image'] as $image): ?>
		 <?php 
		  $i++;
		  echo '<td width="30px"><div style="height: 70px;overflow: none;">';
		  echo $extendedhtml->image('/images/thumb/' . $image['id'] . '/?w=60&h=60', array('class' => 'centeralign'), '/img/' . $image['filename'], array('rel' => 'lytebox'));
		  echo '</div>';
		  echo '</td>';
						 	
		  if($i % 2 == 0)
		   echo '</tr><tr>'; /* only two per line, because long names won't fit :( */	 
		 
		 
		 ?>
		<?php endforeach; ?>
	</tr>
	</table>
	<?php endif; ?>	
	
</div>
<script type="text/javascript">
initialize();
</script>